namespace Creek.Serialize.Advanced
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;

    ///<summary>
    ///</summary>
    internal class PropertyCache
    {
        #region Fields

        private readonly Dictionary<Type, IList<PropertyInfo>> _cache = new Dictionary<Type, IList<PropertyInfo>>();

        #endregion

        #region Public Methods and Operators

        public void Add(Type key, IList<PropertyInfo> value)
        {
            this._cache.Add(key, value);
        }

        /// <summary>
        /// </summary>
        /// <returns> null if the key was not found </returns>
        public IList<PropertyInfo> TryGetPropertyInfos(Type type)
        {
            if (!this._cache.ContainsKey(type))
            {
                return null;
            }
            return this._cache[type];
        }

        #endregion
    }
}